package me.a04test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Test3 {
    public static void main(String[] args) {
        //随机点名
        //已经点到的同学，下次不会被点到
        //如果全部点完，需重新开始第二次点名
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1, "闲", "范建", "范统", "杜子腾", "宋合泛", "侯笼藤", "朱益群", "朱穆朗玛峰");

        //临时存储被点到的同学
        ArrayList<String> list2 = new ArrayList<>();
        //外循环：表示轮数
        for (int i = 1; i <= 10; i++) {
            System.out.println("------------------第" + i + "轮点名-------------------");
            int count = list1.size();
            Random r = new Random();
            //内循环：每一轮随机循环抽取的过程
            for (int j = 0; j < count; j++) {
                int index = r.nextInt(list1.size());
                String name = list1.remove(index);

                list2.add(name);
                System.out.println(name);

            }
            //一轮点名结束
            list1.addAll(list2);
            list2.clear();

        }
    }
}
